<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <!--- __STATIC__  -->
    <script src="/static/js/jquery-3.2.1.min.js"></script></head>
<script src="/static/js/jquery-3.2.1.min.js"></script>
<!-- Site CSS -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
<form method="post" class="panel-body wrapper-lg">
    <label for="username">用户名：</label>
    <input type="text" name="username" id="username"></br></br>
    <label for="password">验证码：</label>
    <input type="code" name="password" id="code"></br></br>
    <label for="password">密码：</label>
    <input type="password" name="password" id="password"></br></br>
    <input type="button" name="button" id="reg-btn" value="注册">

</form>
<script type="text/javascript">
    $("#reg-btn").click(function() {
        var username = $("#username").val();
        var password = $("#password").val();
        //手机号
        var reg = /^1[34578]\d{9}$/;
        if (true !== reg.test(username))
        {
            alert("请输入正确的手机号");
            return false;
        }

        if (username == '' || password == '')
        {
            alert('username or password 不能为空');
            return false;
        }

        $.ajax({
            url: "{:url('backend/Account/doReg')}",
            method: "POST",
            data: {"username": username, "password": password},
            dataType: "json",
            success: function(res) {
                if (res.status === 1)
                {
                    window.location.href = "{:url('backend/Account/login')}";
                }
                else
                {
                    alert(res.msg);
                }
            }
        })
    });
</script>
</body>
</html>